#!/usr/bin/env python
# coding: utf-8

from urllib.request import urlopen, Request
from urllib.parse import urlencode
import hashlib
import time

url="http://msg-sender.weyee.com/qywx"
apikey="replace_to_your_apikey"
query = {
    "title": "python3 urllib.request",
    "content": "测试一下这个模块"
}
query["timestamp"] = int(time.time())
combinStr = "".join([ "%s%s"%(k,query[k]) for k in sorted(query) ]) + apikey
m = hashlib.sha256()
m.update(combinStr.encode())
signature = m.hexdigest()
query["signature"] = signature

req = Request(url, data=urlencode(query).encode())
with urlopen(req) as fPost:
    print(fPost.read().decode())